<template>
  <DataList 
  :cate="cate" 
  :cols="cols"
  :single="true"
  :name="name"

   />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import linq from "linq"
import { addHszh, deleteHszh, updateHszh, getHszh } from "@/api/红十字会.js";
import {findComponent} from "@/utils/ui";
import { Promise } from 'q';
export default {
  components: {
    DataList
  },
  mounted() {
    console.log(this.$root)
  },
  data() {
    return {
      cate: "A10-4红十字会",
      name:'10.4 红十字会',
      cols: [
        { label: "学校分管部门	", prop: "XXFGMC" },
        { label: "社团代码", prop: "STDM" },
        { label: "社团名称", prop: "STMC" },
        { label: "成立日期(年月)", prop: "CLRQ" },
        { label: "会员数量(人)", prop: "会员数量" ,
            data:[
            {label:'总数',prop:'HY_ZS'},
            { label: "教工数", prop: "HY_JGS" },
            { label: "学生数", prop: "HY_XSS" },
        ]},
        { label: "会费情况(元)", prop: "会费情况" ,
            data:[
            {label:'总数',prop:'HF'},
            { label: "上交", prop: "SJHF" },
            { label: "留存自用", prop: "LQHF" },
        ]},
        { label: "会长",
          data: [
            { label: "姓名", prop: "XM" },
            { label: "单位职务", prop: "ZW" },
        ]},
       { label: "活动经费来源(元)",
          data: [
            { label: "总数", prop: "JFLY_ZS" },
            { label: "会费", prop: "JFLY_HF" },
            { label: "学校拨款", prop: "JFLY_BK" },
            { label: "留存自用的捐款", prop: "JFLY_ZY" },
            { label: "其他", prop: "JFLY_QT" },
        ]},
        { label: "捐赠情况(元)", prop: "捐赠情况" ,
            data:[
            {label:'总数',prop:'JKZE'},
            { label: "上交业务", prop: "JKSJYWZGDWE" },
            { label: "留存自用", prop: "JKLYE" },
        ]},
        { label: "主要活动内容", prop: "ZYHDNY" },
        { label: "培训情况", prop: "培训情况" ,
            data:[
            {label:'总数(人次)',prop:'PXQK_ZS'},
            { label: "获得证书数(本)", prop: "PXQK_HDZSS" },
        ]},
        { label: "造血干细胞(人次)", prop: "造血干细胞" ,
            data:[
            {label:'采集数',prop:'ZSGSBCZS'},
            { label: "配对数", prop: "ZSGSBPDS" },
        ]},
        
      ]
    };
  },
   methods: {
    async  onChange(model, field, value) {

    model.HY_ZS = Number(model.HY_JGS)+Number(model.HY_XSS),
    model.HF = Number(model.SJHF)+Number(model.LQHF),
    model.JFLY_ZS = Number(model.JFLY_HF)+Number(model.JFLY_BK)+Number(model.JFLY_ZY)+Number(model.JFLY_QT),
    model.JKZE = Number(model.JKSJYWZGDWE)+Number(model.JKLYE)

    },

    async fetchData() {
      var user = getUser();
 	    var datas = await getHszh(user.XXID,user.CJPC);
      return datas;
    },
   
     onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
       try{     
         
          console.log(JSON.stringify(temp));
          var model = await addHszh(temp);
          resolve(model);
          }catch(e){
        reject(e);
      } 
      });
      
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateHszh(temp);
          resolve(model);
          
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteHszh(temp);
          resolve();
      })
    }
   }
};
</script>
<style>
</style>